package cn.dglydrpy.study.j2ee.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
 * 路径问题：java源代码生成的servlet默认在若url-pama设置为“/xxx”
 * 则会放在应用名（工程名）下，eg,本程序访问网站：http://localhost:8080/j2ee/some
 */
public class SomeServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		System.out.println(username);
		
		response.sendRedirect(request.getContextPath()+"/biz01/b1.jsp");//重定向b1.jsp，浏览器网址改变
		
		//request.getRequestDispatcher("/biz01/b1.jsp").forward(request, response); //转发到b1.jsp,浏览器网址不改变，依旧是/some，
		//转发的地址从应用名的下一级写起，其他都从应用名写起
	}
}
